package hc.bre.rest.cmn

import org.springframework.stereotype.Component
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.mongodb.MongoDatabaseFactory;
import com.mongodb.client.MongoDatabase;

@Component
public class MongoConfig {
	//https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-connecting-to-mongodb

	public final MongoDatabaseFactory mongo;

	@Autowired
	public MongoConfig(MongoDatabaseFactory mongo) {
		//prop in application.properties,eg: spring.data.mongodb.uri=mongodb://jmserver:27017/ruledb
		this.mongo = mongo;
	}

	public void example() {
		MongoDatabase db = mongo.getMongoDatabase();
		// ...
	}

}